package com.sskj.mine.http;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.request.GetRequest;
import com.lzy.okgo.request.PostRequest;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.SPUtil;
import com.sskj.lib.Constans;
import com.sskj.lib.SPConfig;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.util.CommonUtil;
import com.sskj.mine.asset.data.AddresAllBean;
import com.sskj.mine.asset.data.OtherAssetBean;
import com.sskj.mine.asset.data.RechargeBean;
import com.sskj.mine.asset.data.RecordsBean;
import com.sskj.mine.asset.data.WithdrawConfigBean;
import com.sskj.mine.bean.ReWithCoinBean;

import java.util.List;

/**
 * 作者 :吕志豪
 * 简书：https://www.jianshu.com/u/6e525b929aac
 * github：https://github.com/lvzhihao100
 * 描述：
 * 创建时间：2018-10-15 14:08
 */
public class HttpService {

    /**
     * 充值/提币记录
     *
     * @param type recharge 充值 cash 提币
     * @return
     */
    public GetRequest<HttpData<PageBean<RecordsBean>>> getAssetRecord(String code, String type, String p, String size) {
        return OkGo.<HttpData<PageBean<RecordsBean>>>get(HttpConfig.BASE_URL + HttpConfig.GET_ASSET_RECORD)
                .params("id", SPUtil.get(SPConfig.ID, ""))
                .params("type", type)
                .params("stockCode", code)
                .params("pageNumber", p)
                .params("pageSize", size)
                ;
    }






    /**
     * 提币页面
     *
     * @return
     */
    public PostRequest<HttpData<WithdrawConfigBean>> getWithdrawConfig(String code) {
        return OkGo.<HttpData<WithdrawConfigBean>>post(HttpConfig.BASE_URL + HttpConfig.GET_WITHDRAW_CONFIG)
                .params("code", code)
                .params("stockUserId", SPUtil.get(SPConfig.ID, ""))
                ;
    }

    /**
     * 发送验证码（注册）
     *
     * @param mobile 手机号
     * @param type   1注册 （2 重置 3 安全验证 4 资金密码设置 5 提币）
     * @return
     */
    public GetRequest<HttpData> sendSms(String mobile, String type) {
        return OkGo.<HttpData>get(HttpConfig.BASE_URL + HttpConfig.SEND_SMS)
                .params("account", mobile)
                .params("codeType", type);
    }


    /**
     * 提币
     *
     * @param num     数量
     * @param tpwd    资金密码
     * @param code    code
     * @param address 地址
     * @return
     */
    public PostRequest<HttpData> withdraw(String num,String coinType, String stockCode, String tpwd, String code, String address) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.WITHDRAW)
                .params("stockUserId", SPUtil.get(Constans.ID, ""))
                .params("usdFee", num)
                .params("walletAddr", address)
                .params("stockCode", stockCode)
                .params("coinType", coinType)
                .params("code", code)
                .params("tradePwd", tpwd,true);
    }

    /**
     * 币充值页面
     *
     * @return
     */
    public PostRequest<HttpData<RechargeBean>> recharge(String type, String code) {
        return OkGo.<HttpData<RechargeBean>>post(HttpConfig.BASE_URL + HttpConfig.RECHARGE)
                .params("type", type)
                .params("code", code)
                ;
    }



    /**
     * 币充值页面
     *
     * @return
     */
    public GetRequest<HttpData<List<ReWithCoinBean>>> withdrawList() {
        return OkGo.<HttpData<List<ReWithCoinBean>>>get(HttpConfig.BASE_URL + HttpConfig.WITHDRAW_LIST);
    }




    /**
     * 提币地址添加删除
     *
     * @param address 钱包地址
     * @param notes   备注
     * @param type    1btc(usdt) 2eth
     * @return
     */
    public PostRequest<HttpData> addAddress(String address, String notes, String type) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.ADD_ADDRESS)
                .params("toAddr", address)
                .params("stockUserId", SPUtil.get(SPConfig.ID, ""))
                .params("remark", notes)
                .params("type", type);
    }

    /**
     * 提币地址列表
     *
     * @return
     */
    public GetRequest<HttpData<AddresAllBean>> addressList() {
        return OkGo.<HttpData<AddresAllBean>>get(HttpConfig.BASE_URL + HttpConfig.ADDRESS_LIST);
    }


    public GetRequest<HttpData<PageBean<OtherAssetBean.ListBean>>> getOtherAssetRecord(String code, String p, String size) {
        return OkGo.<HttpData<PageBean<OtherAssetBean.ListBean>>>get(HttpConfig.BASE_URL + HttpConfig.OTHER_ASSET_RECORD)
                .params("id", SPUtil.get(SPConfig.ID, ""))
                .params("code", code)
                .params("pageNumber", p)
                .params("pageSize", size);
    }

    public PostRequest<HttpData> cancelTibi(String id) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.CANCEL_TIBI)
                .params("cash_id", id);
    }


    public PostRequest<HttpData> deleteAddress(String id) {
        return OkGo.<HttpData>post(HttpConfig.BASE_URL + HttpConfig.DELETE_ADDRESS)
                .params("id", id);
    }
}